
package org.japril.jhut.framework;

import java.util.HashSet;
import java.util.Set;

public abstract class AbstractWorldValidator implements WorldValidator 
{
  private final Set<String> m_names=new HashSet<String>();
  
  protected AbstractWorldValidator(String... names)
  {
    if (names!=null) for (String n : names) if (n!=null) m_names.add(n);   
  }
  
  /**
   * <p>
   *   Adds name on test {@code this} should validate world for.
   * </p>
   * @param name Name on test.
   */
  public void addTestName(String name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
    
    m_names.add(name);
  }
  
  /**
   * <p>
   *   Removes all names of tests.
   * </p>
   */
  public void clearTestNames(){ m_names.clear(); }
 
  /**
   * <p>
   *   Removes name on test.
   * </p>
   * @param name Name to remove.
   */
  public void removeTestName(String name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
  }

  // Specified in WorldValidator. 
  public Set<String> getTestNames(){ return new HashSet<String>(m_names); }
  
}
